layui.use(['laydate','form','table','layer'], function(){
	var laydate = layui.laydate,form = layui.form,table = layui.table,layer = layui.layer;

	/*@初始化table*/
	var tableObj = table.render({
	    elem: '#shop-list',
	    url: '/staff/staff/shop_list', //数据接口
	    page: false, //开启分页
	    limits: false,
	    cols: [[ //表头
	    	{field: 'admin_sn', title: '员工编号'},
	    	{field: 'nkname', title: '姓名'},
	    	{field: 'sex_text', title: '性别', width: 60},
	    	{field: 'shop_name', title: '所属部门'},
	    	{field: 'g_title', title: '员工职位'},
	    	{field: 'phone', title: '联系方式'},
	    	{field: 'addtime', title: '入职日期'},
	    	{title: '销售总盈利(元)', toolbar: '<div>{{d.count_order.sale}}</div>'},
	    	{title: '维修总盈利(元)', toolbar: '<div>{{d.count_repair.people_money}}</div>'},
	    	{title: '操作', toolbar: '#table-btn', width: 300}
	    ]]
	});
	/*@查询*/
	form.on('submit(search)',function(data){

		if(data.field.start != '' && data.field.end != ''){
			var startDate = new Date(data.field.start).getTime();
			var endDate = new Date(data.field.end).getTime();
			if(startDate > endDate){
				layer.msg('开始时间不能大于结束时间',{icon: 2})
				return false
			}
		}
		/*重载表格数据*/
		tableObj.reload({
			page: {
                page: 1 //重新从第 1 页开始
            },
            where: data.field
        });
        return false
	})
});